const {ccclass, property} = cc._decorator;
import { Macros } from "./Common/AppMacros"
@ccclass
class MapMgr extends cc.Component {

    @property(cc.SpriteFrame)
    private bgFrame:cc.SpriteFrame;

    public static Instance: MapMgr;

    public onLoad() {
        cc.director.setDisplayStats(true);
        MapMgr.Instance = this;
        for (var i = 0; i < Macros.MAP_WIDTH_NUM; i++) {
            for (var j = 0; j < Macros.MAP_HEIGHT_NUM; j++) {
                let mapCell = new cc.Node();
                mapCell.parent = this.node;
                let cellSprite:cc.Sprite = <cc.Sprite>mapCell.addComponent(cc.Sprite);
                cellSprite.spriteFrame = this.bgFrame;
                mapCell.x = (2 * i - Macros.MAP_WIDTH_NUM + 1) * Macros.MAP_CELL_NUM * 0.5;
                mapCell.y = (2 * j - Macros.MAP_HEIGHT_NUM + 1) * Macros.MAP_CELL_NUM * 0.5;
                
            }
            
        }
    }
}
